package com.phantasy.scene.sceneKit
{
	import com.phantasy.scene.sceneUnit.baseUnit.SceneStyle;
	import com.phantasy.utils.HtmlUtil;
	
	import flash.display.Sprite;
	import flash.geom.Rectangle;
	import flash.text.TextField;
	import flash.text.TextFieldAutoSize;
	import flash.text.TextFormat;

	/**
	 * 
	 * @author Liseen
	 * 
	 */	
	public class RoleNameItem extends Sprite
	{
		private static const FACE_ICON_SIZE:int = 24;
		
		private var textField:TextField;
		public var addHtmlText:String = "";
		private var myFacePattern:RegExp;
		private var faceTextFormat:TextFormat;
		private var _height:Number;
		private var faces:Array;
		public var data:Object;
		public var handler:Function;
		private var pattern:RegExp;
		public var reg:RegExp;
		
		public function RoleNameItem(str:String)
		{
			this.myFacePattern = /00·/g;
			this.pattern = /(\/\d{2})/g;
			this.reg = /\/\d{2}/;
			super();
			this.faceTextFormat = new TextFormat();
			this.textField = new TextField();
			this.textField.autoSize = TextFieldAutoSize.LEFT;
			this.textField.condenseWhite = false;
			this.textField.filters = SceneStyle.nameFilter;
			addChild(this.textField);
			this.faces = [];
			this.mouseEnabled = false;
			this.mouseChildren = false;
			this.setHtmlText(HtmlUtil.font(str, "#ffffff"));
			this.x = int((-(this.width) / 2));
		}
		
		public function multiline(_arg1:Boolean):void
		{
			this.textField.wordWrap = _arg1;
			this.textField.multiline = _arg1;
		}
		
		public function set txtWidth(_arg1:Number):void
		{
			this.textField.width = _arg1;
		}
		
		public function set textColor(_arg1:uint):void
		{
			this.textField.textColor = _arg1;
		}
		
		public function get text():String
		{
			return (this.textField.text);
		}
		
		public function setTextFormat(_arg1:TextFormat):void
		{
			this.textField.setTextFormat(_arg1);
		}
		
		public function setHtmlText(_arg1:String):void
		{
			_arg1 = _arg1.replace(this.pattern, "$& ");
			this.addHtmlText = _arg1;
			this.textField.htmlText = this.addHtmlText;
			if (this._height != Math.floor((this.textField.textHeight + 6)))
			{
				this._height = (this.textField.height = Math.floor((this.textField.textHeight + 6)));
			};
			this.setFaces();
			if (this.x != Math.floor((-(this.width) / 2)))
			{
				this.x = Math.floor((-(this.width) / 2));
			}
		}
		
		private function setFaces():void
		{
			var _local1:Array = this.textField.text.split(/(\/\d{2})/);
			if (((!(_local1)) || ((_local1.length == 0))))
			{
				return;
			};
			var _local2:int;
			var _local3:int;
			while (_local3 < _local1.length)
			{
				if (((((this.reg.test(_local1[_local3])) && ((int(String(_local1[_local3]).slice(1, 3)) > 0)))) && ((int(String(_local1[_local3]).slice(1, 3)) <= 36))))
				{
					this.addImg(int(String(_local1[_local3]).slice(1, 3)).toString(), this.textField.getCharBoundaries(_local2));
					this.textField.replaceText(_local2, (_local2 + 3), "00·");
					_local2 = (_local2 + String(_local1[_local3]).length);
				}
				else
				{
					_local2 = (_local2 + String(_local1[_local3]).length);
				};
				_local3++;
			};
			this.textField.htmlText = this.textField.htmlText.replace(this.myFacePattern, "      ");
		}
		
		private function addImg(_arg1:String, _arg2:Rectangle):void
		{
		}
	}
}